<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
    <style>
        .header {
            background-color: hotpink;
            height: 50px;
        }

        .container {
            display: flex;
        }

        .navbar {
            width: 200px;
            height: 500px;
            background-color: lightblue;
            flex-shrink: 0;
        }

        .body {
            flex-grow: 1;
            background-color: lightgreen;
            height: 500px;
        }
    </style>
</head>

<body>
    <div id='app'>
        <router-view></router-view>
        
    </div>

    <template id="indexTemp">
        <div>
            <header class="header">头部</header>
            <section class="container">
                <div class="navbar">
                    <router-link to="/index/login">登录</router-link>
                    <router-link to="/index/register">注册</router-link>
                </div>
                <div class="body">
                    <router-view></router-view>
                </div>
            </section>
        </div>
    </template>
    <script>
        const index = {
            template: '#indexTemp'
        }

        const login = {
            template: `<div>登录</div>`
        }

        const register = {
            template: `<div>注册</div>`
        }

        const router = new VueRouter({
            routes: [{
                path: '/',
                redirect: '/index'
            }, {
                path: '/index',
                component: index,
                children: [
                    {
                        path: 'login',
                        component: login
                    },
                    {
                        path: 'register',
                        component: register
                    },
                ]
            }]
        })

        const vm = new Vue({
            el: '#app',
            data: {},
            router
        })
    </script>
</body>

</html>